// 引入mongoose
const mongoose = require("mongoose");
const moment = require("moment-timezone");
// 创建我的购物车集合规则
const myShopCarSchema = new mongoose.Schema({
    // 修改时间
    modify: {
        type: String,
        default: moment().tz("Asia/Shanghai").format("YYYY/MM/DD HH:mm:ss"),
    },
    // 商品是否被删除
    // display: {
    //     type: Boolean,
    //     required: [true, "商品是否被删除不能为空"],
    // },
    // 用户id
    uid: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "User",
        required: [true, "用户id不能为空"],
    },
    // 商品id
    sid: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "Goods",
        required: [true, "商品id不能为空"],
    },
    // 商品数量
    count: {
        type: Number,
        required: [true, "商品数量不能为空"],
    },
});
// 创建我的购物车集合
const MyShopCar = mongoose.model("MyShopCar", myShopCarSchema);
// 导出集合
module.exports = MyShopCar;